<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>社交平台顶部导航</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  
  <style>
    :root {
      --primary: #3B82F6;
      --secondary: #10B981;
      --danger: #EF4444;
      --light: #F9FAFB;
      --dark: #1F2937;
      --light-gray: #E5E7EB;
      --dark-gray: #6B7280;
      --white: #FFFFFF;
      --border-light: #E5E7EB;
      --border-dark: #374151;
    }
    
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: var(--light);
      color: var(--dark);
      height: 100vh;
      overflow-x: hidden;
      margin: 0;
      padding-top: 56px; /* 为顶部导航留出空间 */
    }
    
    /* 页面容器 */
    .page-container {
      display: none;
      height: 100%;
    }
    
    .page-container.active {
      display: block;
    }
    
    /* 页面内容 */
    .page-content {
      padding: 20px;
      text-align: center;
      min-height: calc(100vh - 56px);
    }
    
    .page-title {
      font-size: 24px;
      font-weight: 600;
      margin-bottom: 20px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--border-light);
    }
    
    .dark .page-title {
      color: var(--white);
      border-bottom-color: var(--border-dark);
    }
    
    /* 顶部导航基础样式 */
    .top-nav {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 56px;
      display: flex;
      align-items: center;
      background-color: var(--white);
      border-bottom: 1px solid var(--border-light);
      z-index: 1000;
      padding: 0 16px;
    }
    
    .dark .top-nav {
      background-color: #111827;
      border-bottom-color: var(--border-dark);
    }
    
    .nav-brand {
      font-size: 20px;
      font-weight: 600;
      color: var(--primary);
      text-decoration: none;
    }
    
    .nav-title {
      font-size: 18px;
      font-weight: 600;
      margin: 0 auto;
    }
    
    .dark .nav-title {
      color: var(--white);
    }
    
    .nav-actions {
      display: flex;
      gap: 16px;
    }
    
    .nav-action {
      color: var(--dark-gray);
      background: none;
      border: none;
      font-size: 20px;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
    }
    
    .dark .nav-action {
      color: #9CA3AF;
    }
    
    .nav-action:hover {
      background-color: var(--light-gray);
    }
    
    .dark .nav-action:hover {
      background-color: #374151;
    }
    
    /* 风格1: 品牌标识导航 */
    .style-brand .top-nav {
      justify-content: space-between;
    }
    
    .style-brand .nav-title {
      display: none;
    }
    
    /* 风格2: 居中标题导航 */
    .style-centered .top-nav {
      justify-content: space-between;
    }
    
    .style-centered .nav-brand {
      display: none;
    }
    
    /* 风格3: 搜索栏导航 */
    .style-search .top-nav {
      height: 64px;
      flex-direction: column;
      justify-content: center;
      padding: 8px 16px;
    }
    
    .style-search .nav-elements {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
    }
    
    .style-search .search-container {
      width: 100%;
      position: relative;
    }
    
    .style-search .search-input {
      width: 100%;
      padding: 8px 16px 8px 40px;
      border-radius: 20px;
      border: 1px solid var(--border-light);
      background-color: var(--light);
      font-size: 14px;
    }
    
    .dark .style-search .search-input {
      background-color: #1F2937;
      border-color: var(--border-dark);
      color: var(--white);
    }
    
    .style-search .search-icon {
      position: absolute;
      left: 14px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--dark-gray);
    }
    
    /* 风格4: 标签页导航 */
    .style-tabs .top-nav {
      height: auto;
      flex-direction: column;
      padding: 0;
    }
    
    .style-tabs .nav-header {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-light);
    }
    
    .dark .style-tabs .nav-header {
      border-bottom-color: var(--border-dark);
    }
    
    .style-tabs .tabs-container {
      width: 100%;
      display: flex;
      overflow-x: auto;
      scrollbar-width: none;
    }
    
    .style-tabs .tabs-container::-webkit-scrollbar {
      display: none;
    }
    
    .style-tabs .tab-item {
      padding: 12px 20px;
      white-space: nowrap;
      font-size: 15px;
      font-weight: 500;
      color: var(--dark-gray);
      border-bottom: 3px solid transparent;
      cursor: pointer;
    }
    
    .dark .style-tabs .tab-item {
      color: #9CA3AF;
    }
    
    .style-tabs .tab-item.active {
      color: var(--primary);
      border-bottom-color: var(--primary);
    }
    
    /* 风格5: 深色模式导航 */
    .dark {
      background-color: var(--dark);
      color: var(--white);
    }
    
    /* 通知徽章 */
    .badge {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background-color: var(--danger);
      color: white;
      font-size: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    /* 样式切换器 */
    .style-switcher {
      position: fixed;
      top: 70px;
      right: 16px;
      z-index: 1001;
      background-color: white;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      overflow: hidden;
    }
    
    .dark .style-switcher {
      background-color: #1F2937;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .switcher-header {
      padding: 8px 12px;
      font-size: 14px;
      font-weight: 500;
      border-bottom: 1px solid var(--border-light);
    }
    
    .dark .switcher-header {
      border-bottom-color: var(--border-dark);
      color: var(--white);
    }
    
    .style-option {
      padding: 10px 16px;
      font-size: 14px;
      cursor: pointer;
    }
    
    .style-option:hover {
      background-color: var(--light);
    }
    
    .dark .style-option {
      color: var(--white);
    }
    
    .dark .style-option:hover {
      background-color: #374151;
    }
    
    .style-option.active {
      background-color: var(--primary);
      color: white;
    }
  </style>
</head>
<body>
  <!-- 样式切换器 -->
  <div class="style-switcher">
    <div class="switcher-header">顶部导航样式</div>
    <div class="style-option active" data-style="brand">品牌标识</div>
    <div class="style-option" data-style="centered">居中标题</div>
    <div class="style-option" data-style="search">搜索栏</div>
    <div class="style-option" data-style="tabs">标签页</div>
    <div class="style-option" data-style="dark">深色模式</div>
  </div>
  
  <!-- 品牌标识导航页面 -->
  <div class="page-container active style-brand" id="brandPage">
    <nav class="top-nav">
      <a href="#" class="nav-brand">Social</a>
      <div class="nav-actions">
        <button class="nav-action" aria-label="搜索">
          <i class="fa fa-search"></i>
        </button>
        <button class="nav-action" aria-label="消息">
          <i class="fa fa-bell"></i>
          <span class="badge">2</span>
        </button>
        <button class="nav-action" aria-label="个人中心">
          <i class="fa fa-user-circle-o"></i>
        </button>
      </div>
    </nav>
    
    <div class="page-content">
      <h1 class="page-title">首页</h1>
      <p>这是品牌标识风格的顶部导航示例</p>
      <p>左侧显示品牌名称，右侧为功能按钮</p>
    </div>
  </div>
  
  <!-- 居中标题导航页面 -->
  <div class="page-container style-centered" id="centeredPage">
    <nav class="top-nav">
      <div class="nav-actions">
        <button class="nav-action" aria-label="菜单">
          <i class="fa fa-bars"></i>
        </button>
      </div>
      <h1 class="nav-title">首页</h1>
      <div class="nav-actions">
        <button class="nav-action" aria-label="消息">
          <i class="fa fa-envelope-o"></i>
          <span class="badge">3</span>
        </button>
        <button class="nav-action" aria-label="设置">
          <i class="fa fa-cog"></i>
        </button>
      </div>
    </nav>
    
    <div class="page-content">
      <h1 class="page-title">首页</h1>
      <p>这是居中标题风格的顶部导航示例</p>
      <p>中间显示页面标题，两侧为功能按钮</p>
    </div>
  </div>
  
  <!-- 搜索栏导航页面 -->
  <div class="page-container style-search" id="searchPage">
    <nav class="top-nav">
      <div class="nav-elements">
        <button class="nav-action" aria-label="菜单">
          <i class="fa fa-bars"></i>
        </button>
        <h1 class="nav-title">发现</h1>
        <button class="nav-action" aria-label="个人中心">
          <i class="fa fa-user-circle-o"></i>
        </button>
      </div>
      <div class="search-container">
        <i class="fa fa-search search-icon"></i>
        <input type="text" class="search-input" placeholder="搜索用户、话题或内容...">
      </div>
    </nav>
    
    <div class="page-content">
      <h1 class="page-title">发现</h1>
      <p>这是带搜索栏的顶部导航示例</p>
      <p>包含搜索功能，适合内容探索页面</p>
    </div>
  </div>
  
  <!-- 标签页导航页面 -->
  <div class="page-container style-tabs" id="tabsPage">
    <nav class="top-nav">
      <div class="nav-header">
        <a href="#" class="nav-brand">Feed</a>
        <div class="nav-actions">
          <button class="nav-action" aria-label="消息">
            <i class="fa fa-bell"></i>
            <span class="badge">5</span>
          </button>
        </div>
      </div>
      <div class="tabs-container">
        <div class="tab-item active" data-tab="following">关注</div>
        <div class="tab-item" data-tab="trending">热门</div>
        <div class="tab-item" data-tab="recommended">推荐</div>
        <div class="tab-item" data-tab="latest">最新</div>
        <div class="tab-item" data-tab="groups">群组</div>
      </div>
    </nav>
    
    <div class="page-content">
      <h1 class="page-title">关注内容</h1>
      <p>这是标签页风格的顶部导航示例</p>
      <p>可横向滑动切换不同内容分类</p>
    </div>
  </div>
  
  <!-- 深色模式导航页面 -->
  <div class="page-container style-brand dark" id="darkPage">
    <nav class="top-nav">
      <a href="#" class="nav-brand">Social</a>
      <div class="nav-actions">
        <button class="nav-action" aria-label="搜索">
          <i class="fa fa-search"></i>
        </button>
        <button class="nav-action" aria-label="消息">
          <i class="fa fa-bell"></i>
          <span class="badge">2</span>
        </button>
        <button class="nav-action" aria-label="个人中心">
          <i class="fa fa-user-circle-o"></i>
        </button>
      </div>
    </nav>
    
    <div class="page-content">
      <h1 class="page-title">首页</h1>
      <p>这是深色模式的顶部导航示例</p>
      <p>适合夜间使用，减少视觉疲劳</p>
    </div>
  </div>
  
  <!-- Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <script>
    // 获取DOM元素
    const styleOptions = document.querySelectorAll('.style-option');
    const pageContainers = document.querySelectorAll('.page-container');
    const tabItems = document.querySelectorAll('.tab-item');
    const navActions = document.querySelectorAll('.nav-action');
    
    // 当前激活的样式
    let currentStyle = 'brand';
    
    // 切换导航样式
    styleOptions.forEach(option => {
      option.addEventListener('click', function() {
        // 更新样式选项的活跃状态
        styleOptions.forEach(opt => opt.classList.remove('active'));
        this.classList.add('active');
        
        // 获取选中的样式
        currentStyle = this.getAttribute('data-style');
        
        // 隐藏所有页面
        pageContainers.forEach(page => page.classList.remove('active'));
        
        // 显示对应样式的页面
        const stylePage = document.getElementById(`${currentStyle}Page`);
        if (stylePage) {
          stylePage.classList.add('active');
          
          // 更新页面内容
          updatePageContent(stylePage);
        }
      });
    });
    
    // 标签页切换
    tabItems.forEach(tab => {
      tab.addEventListener('click', function() {
        // 移除所有标签的活跃状态
        tabItems.forEach(item => item.classList.remove('active'));
        
        // 添加当前标签的活跃状态
        this.classList.add('active');
        
        // 更新页面内容
        const tabName = this.getAttribute('data-tab');
        const tabTitles = {
          'following': '关注内容',
          'trending': '热门内容',
          'recommended': '推荐内容',
          'latest': '最新内容',
          'groups': '群组内容'
        };
        
        const activePage = document.querySelector('.page-container.active');
        if (activePage) {
          const pageTitleElement = activePage.querySelector('.page-title');
          if (pageTitleElement) {
            pageTitleElement.textContent = tabTitles[tabName] || '内容页面';
          }
        }
      });
    });
    
    // 导航操作按钮点击事件
    navActions.forEach(action => {
      action.addEventListener('click', function() {
        const icon = this.querySelector('i');
        let actionName = '';
        
        if (icon.classList.contains('fa-search')) actionName = '搜索';
        else if (icon.classList.contains('fa-bell')) actionName = '通知';
        else if (icon.classList.contains('fa-user-circle-o')) actionName = '个人中心';
        else if (icon.classList.contains('fa-bars')) actionName = '菜单';
        else if (icon.classList.contains('fa-envelope-o')) actionName = '消息';
        else if (icon.classList.contains('fa-cog')) actionName = '设置';
        
        alert(`打开${actionName}功能`);
      });
    });
    
    // 更新页面内容
    function updatePageContent(pageContainer) {
      const styleTitles = {
        'brand': '首页',
        'centered': '首页',
        'search': '发现',
        'tabs': '关注内容',
        'dark': '首页'
      };
      
      const styleDescriptions = {
        'brand': '左侧显示品牌名称，右侧为功能按钮',
        'centered': '中间显示页面标题，两侧为功能按钮',
        'search': '包含搜索功能，适合内容探索页面',
        'tabs': '可横向滑动切换不同内容分类',
        'dark': '适合夜间使用，减少视觉疲劳'
      };
      
      const pageTitleElement = pageContainer.querySelector('.page-title');
      const pageDescElement = pageContainer.querySelector('.page-content p:nth-child(3)');
      
      if (pageTitleElement && pageDescElement) {
        pageTitleElement.textContent = styleTitles[currentStyle] || '页面';
        pageDescElement.textContent = styleDescriptions[currentStyle] || '社交平台页面';
      }
    }
  </script>
</body>
</html>
